mod gui;
mod shell;
mod widgets;

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
    let options = eframe::NativeOptions {
        viewport: egui::ViewportBuilder::default()
            .with_inner_size([800.0, 600.0])
            .with_title("Simple GUI"),
        ..Default::default()
    };

    eframe::run_native(
        "Terminal Buddy 终端小伙",
        options,
        Box::new(|cc| {
            // 设置中文字体
            let mut fonts = egui::FontDefinitions::default();
            fonts.font_data.insert(
                "SourceHanSansCN".to_owned(),
                egui::FontData::from_static(include_bytes!("../fonts/SourceHanSansCN-Regular.otf"))
                    .into(),
            );
            fonts
                .families
                .get_mut(&egui::FontFamily::Proportional)
                .unwrap()
                .insert(0, "SourceHanSansCN".to_owned());
            cc.egui_ctx.set_fonts(fonts);

            Ok(Box::new(gui::SimpleGui::new()))
        }),
    )
}
